delete from dbo.stdtabelasvar where tabela = 'TDU_Venda';
delete from dbo.stdcamposvar where tabela = 'TDU_Venda';
insert into dbo.stdtabelasvar values('TDU_Venda', 'ERP');
insert into dbo.stdcamposvar (tabela, campo, descricao, texto, visivel, ordem) values('TDU_Venda', 'CDU_Id', 'Id', 'Id', 1, 1);
insert into dbo.stdcamposvar (tabela, campo, descricao, texto, visivel, ordem) values('TDU_Venda', 'CDU_Vendedor', 'Vendedor', 'Vendedor', 1, 2);
insert into dbo.stdcamposvar (tabela, campo, descricao, texto, visivel, ordem) values('TDU_Venda', 'CDU_Zona', 'Zona', 'Zona', 1, 3);
insert into dbo.stdcamposvar (tabela, campo, descricao, texto, visivel, ordem) values('TDU_Venda', 'CDU_Morada', 'Morada', 'Morada', 1, 4);
insert into dbo.stdcamposvar (tabela, campo, descricao, texto, visivel, ordem) values('TDU_Venda', 'CDU_Contacto', 'Contacto', 'Contacto', 1, 5);
go

CREATE TABLE [dbo].[TDU_Venda](
	CDU_Id [bigint] IDENTITY(1,1) NOT NULL,
	CDU_Vendedor [nvarchar](3) NULL,
	CDU_Zona [nvarchar](50) NULL,
	CDU_Morada [nvarchar](50) NULL,
	CDU_Contacto [nvarchar](20) NULL,
 CONSTRAINT [PK_TDU_Venda] PRIMARY KEY CLUSTERED 
(
	[CDU_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[TDU_Venda]  WITH CHECK ADD  CONSTRAINT [FK_TDU_Venda_Vendedores] FOREIGN KEY([CDU_Vendedor])
REFERENCES [dbo].[Vendedores] ([Vendedor])
GO

ALTER TABLE [dbo].[TDU_Venda] CHECK CONSTRAINT [FK_TDU_Venda_Vendedores]
GO


